﻿<Popup x:Class="Monti.AutoComplete.AutoCompletePopup"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:mvvm="clr-namespace:Monti.MVVM" xmlns:Commands="clr-namespace:Monti.MVVM.Commands" mc:Ignorable="d"
       d:DesignHeight="300"
       d:DesignWidth="300">
   <Grid>
      <Grid.Resources>
         <Style TargetType="{x:Type ListBoxItem}">

            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="{x:Type ListBoxItem}">
                     <Border x:Name="Border"
                             BorderBrush="{TemplateBinding BorderBrush}"
                             BorderThickness="{TemplateBinding BorderThickness}"
                             Background="{TemplateBinding Background}"
                             Padding="{TemplateBinding Padding}"
                             SnapsToDevicePixels="true">
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Margin="0 1 0 2" />
                     </Border>
                     <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected"
                                 Value="true">
                           <Setter Property="Background"
                                   TargetName="Border"
                                   Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                           <Setter Property="Foreground"
                                   Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                        </Trigger>
                     </ControlTemplate.Triggers>
                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Style>
      </Grid.Resources>
      <ListBox Focusable="False"
               ItemsSource="{Binding Path=ListItems}"
               SelectedIndex="{Binding Path=SelectedIndex}"
               SelectedItem="{Binding Path=SelectedListItem}">
         <Commands:CommandBehaviorCollection.Behaviors>
            <Commands:CommandBehavior Event="PreviewMouseMove"
                                  Command="{Binding Path=MouseMoveCommand}" />
            <Commands:CommandBehavior Event="PreviewMouseLeftButtonDown"
                                  Command="{Binding Path=MouseLeftDownCommand}" />
            <Commands:CommandBehavior Event="PreviewMouseLeftButtonUp"
                                  Command="{Binding Path=MouseLeftUpCommand}" />
         </Commands:CommandBehaviorCollection.Behaviors>
      </ListBox>
      <!--mvvm:ControlBehaviors.PreviewMouseMoveCommand="{Binding Path=MouseMoveCommand}"
      mvvm:ControlBehaviors.PreviewMouseLeftButtonDownCommand="{Binding Path=MouseLeftDownCommand}"
      mvvm:ControlBehaviors.PreviewMouseLeftButtonUpCommand="{Binding Path=MouseLeftUpCommand}" />-->
   </Grid>
</Popup>
